float nearDistance : register(C0);
float farDistance : register(C1);
unorm float tooNear : register(C2);
unorm float tooFar : register(C3);
unorm float unknown : register(C4);

texture2D BackgroundTexture : register(S0);
texture2D ColorSampler1 : register(S1);
texture2D ColorSampler2 : register(S2);

texture2D DepthTextureBackground: register(S3);
texture2D DepthTexture1 : register(S4);
texture2D DepthTexture2 : register(S5);

sampler DepthSamplerBackground
{
	Texture = (DepthTextureBackground);
	MinFilter = Point;
	MagFilter = Point;
	MipFilter = Point;
	AddressU = Wrap;
	AddressV = Wrap;
};

sampler DepthSampler1
{
	Texture = (DepthTexture1);
	MinFilter = Point;
	MagFilter = Point;
	MipFilter = Point;
	AddressU = Wrap;
	AddressV = Wrap;
};

sampler DepthSampler2
{
	Texture = (DepthTexture2);
	MinFilter = Point;
	MagFilter = Point;
	MipFilter = Point;
	AddressU = Wrap;
	AddressV = Wrap;
};

SamplerState s;

float4 main(float2 uv : TEXCOORD) : SV_TARGET
{
	//return ColorSampler2.Sample(s,uv);
	//float4 texColor = diffuseMap.Sample(DiffuseSampler, In.texCoord);
	float depthBackground = tex2D(DepthSamplerBackground, uv).r;
	float depth1 = tex2D(DepthSampler1, uv).r;
	float depth2 = tex2D(DepthSampler2, uv).r;

	//if (depth1 < nearDistance) {
	//	return float4(1,1,0,1);
	//}
	//
	//if (depth1 > farDistance) {
	//	return float4(0,1,1,1); //
	//}

	//if (depthBackground < depth1 && depthBackground < depth2) {

	//	return BackgroundTexture.Sample(s, uv);
	//}

	//if (depth2 < depth1) {
	//	return ColorSampler2.Sample(s, uv);
	//}

	// Returned if depth1 is least or all are equal
	return ColorSampler1.Sample(s, uv);
}


